package spring.security.web.aspect;

import java.util.Date;

import org.aspectj.lang.ProceedingJoinPoint;

//@Aspect
//@Component
public class TimeAspect {
	
	//在执行控制器方法之前执行
	//@Before(value = "")
	//在执行控制器方法(成功返回)之后执行
	//@After(value = "")
	//在执行控制器方法(异常返回)之后执行
	//@AfterThrowing
	//包围:完全覆盖上面三种(推荐)
	//@Around("execution(* spring.security.web.controller.UserController.*(..))")
	public Object execution(ProceedingJoinPoint pjp) throws Throwable {
		System.out.println("time aspect");
		Object[] args = pjp.getArgs();//获取参数
		System.out.println(args);
		long start = new Date().getTime();
		Object object = pjp.proceed();
		long end = new Date().getTime();
		System.out.println("time aspect: 耗时" + (end - start));
		System.out.println(object);
		return object;
	}
	
}
